<#include "../public/header.html">
<link href="public/themes/talent.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="public/kindeditor/kindeditor.js"></script>
<script type="text/javascript" src="public/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript" src="public/js/ajaxUploadFile.js"></script>

    <div id="editdlg">
    </div>
        <div id="tb" style="padding:5px 5px; border-bottom: dashed #d2d2d2 1px;margin-bottom: 5px;">
            
        </div>
回复类型：<input class="easyui-combobox" id="reply_type"  name="reply_type" value="${(po.reply_type!)!}" data-options="url:'admin/WXReply/sys_pa_code?table=wx_aut_reply&field=reply_type',method:'get',valueField:'id',textField:'name',panelHeight:'auto',onSelect:reply_change">
<br/>
状&nbsp;&nbsp;态：<input class="easyui-combobox" type="text" name="status" value="${(po.status!)!}" data-options="url:'admin/WXReply/sys_pa_code?table=wx_aut_reply&field=status',method:'get',valueField:'id',textField:'name',panelHeight:'auto'">
 <br/>
 <div id="keyword_id">
         关键字:
		<input type="text" class="input" size="80" id="key_word" name="key_word" value="${(po.key_word!)!}" />
        <font color="red">*</font>（多个关键字用“,”隔开；例：考证,保育员）
</div>      
        <div id="Right" style="height: 100%; width: 1236px;overflow:auto;">
            <div id="tb" style="padding:5px 5px; border-bottom: dashed #d2d2d2 1px;margin-bottom: 5px;">
            
        	</div>
            <input type="hidden" id="talent_id" value="">
            <input type="hidden" id="msg_type" value="707">
            <div class="main_bd_one">
                <div class="main_bd_one_left" style="height: 300px;">
                    <div class="content">
                        <div class="title">
                            <span id="span_title_id">标题</span>
                        </div>
                        <div class="img_area">
                            <img class="img_view" id="img_view" src="">
                            <li class="view_default">封面图片</li>
                        </div>
                        <div class="description">
                            <span id="span_description_id">摘要</span>
                        </div>
                    </div>
                </div>
                <div class="main_bd_one_right" style="height: 650px; ">
                    <input type="hidden" id="talent_detail_id" value="">
                    <div class="content">
                        <div class="input_tab">
                            <div class="input_tab_title">
                                <span>标题</span>
                            </div>
                            <input type="text" class="input" id="title" oninput="title_on_change()" size="60">
                        </div>
                        <div class="input_tab">
                            <div class="input_tab_title">
                                <span>封面</span> <span style="font-size: 12px; color: #868686">（大图片建议尺寸：900像素 * 500像素）</span>
                            </div>
                            <input type="hidden" id="pic_url" value="">
                            <input type="file" class="input" size="60" name="file_name" id="fileToUpload">
                            <input type="button" class="btn" value="上传" onclick="ajaxFileUpload()">
                        </div>
                        <div class="input_tab">
                            <img src="" id="page_img" style="width: 40px;height: 40px;display: none">
                        </div>
                        <div class="input_tab">
                            <div class="input_tab_title">
                                <span>摘要</span>
                            </div>
                            <textarea rows="5" cols="60" id="description" oninput="title_on_description()"></textarea>
                        </div>
                        <div class="input_tab">
                            <div class="input_tab_title">
                                <span>跳转URL</span>
                            </div>
                            <input type="text" class="input" id="url" size="60">
                        </div>
                        <div class="input_tab">
                            <div class="input_tab_title">
                                <span>正文</span>
                            </div>
                            <textarea style="height: 200px; width: 100%;" id="content"></textarea>
                        </div>

                        <div class="input_tab" style="text-align: center">
                            <br>
                            <button class="btn submit" onclick="add()">提交</button>
                        </div>

                    </div>

                </div>
            </div>
        </div>
		<script type="text/javascript">
			var content_edit;
		
	    	KindEditor.ready(function(K) {
	                content_edit = K.create('#content',{
											             uploadJson : 'admin/File/upload'
											         });
	        });
	       $(function(){
	            $("#tb").prependTo(".datagrid-toolbar");
	        })
	        function reply_change(){
			    var reply_type = $("#reply_type").combobox("getValue"); 
			    if(reply_type==701){
			        $("#keyword_id").hide();
			    }else{
			        $("#keyword_id").show();
			
			    }
			}
	        function title_on_change(){
	            var title = $("#title").val();
	            if(title == ""){
	                title="标题"
	            }
	            $("#span_title_id").html(title);
	        }
	         function title_on_description(){
	            var title = $("#description").val();
	            if(title == ""){
	                title=""
	            }
	            $("#span_description_id").html(title);
	        }
	        function ajaxFileUpload() {
	            $.ajaxFileUpload
	            (
	                    {
	                        url: 'admin/File/upload',
	                        secureuri: false,
	                        fileElementId: 'fileToUpload',
	                        dataType:"json",
	                        success: function(result,status) {
	                            //tip("上传图片",data.msg)
	                            if(result.error == 0){
	                                $("#page_img").attr("src",""+result.url);
	                                $("#img_view").attr("src",""+result.url);
	                                $(".view_default").hide();
	                                $("#img_view").show();
	                                $("#page_img").show();
	                                $("#pic_url").val(result.url);
	                            }
	                        },
	                        handleError:function(s, xml, status, e){
	
	                        }
	                    }
	            );
	            return false;
	
	        }
	        
	        function add(){

	            content_edit.sync();
	
	            var title = $("#title").val();
	            var pic_url = $("#pic_url").val();
	            var description = $("#description").val();
	            var url = $("#url").val();
	            var content = $("#content").val();
	
	            if(title == null || title ==""){
	                $.messager.alert("数据校验","标题不能为空！");
	                return ;
	            }
	            if(pic_url == null || pic_url ==""){
	                $.messager.alert("数据校验","封面不能为空！");
	                return ;
	            }
	            if(description == null || description ==""){
	                $.messager.alert("数据校验","摘要不能为空！");
	                return ;
	            }
	
	            $.ajax({
	                url:"admin/WXTalent/saveone",
	                type:"post",
	                dataType:"json",
	                data:{talent_id:$("#talent_id").val(),talent_detail_id:$("#talent_detail_id").val(),title:title,pic_url:pic_url,description:description,url:url,content:content},
	                success:function(data){
	                    $.messager.alert("保存数据",data.msg);
	                    if(data.state==1){
	                        setTimeout(function(){window.location="admin/WXTalent/index";},1000);
	                    }
	                }
	            });
	        }
	        
	        
	    </script>
    
    <#include "../public/footer.html">